package com.jgy.service.impl;

import com.jgy.service.CommonService;
import com.jgy.utils.SpringBeanUtils;
import org.springframework.stereotype.Service;


import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author 姜光远
 * @date 2023/7/1 19:37
 */
@Service(value = "commonService")
public class CommonServiceImpl implements CommonService {

    @Override
    public Object publish() throws ClassNotFoundException {

        Class<?> aClass = Class.forName("com.jgy.service.impl.XmcDataServiceImpl");



        XmcDataServiceImpl xmcDataService = (XmcDataServiceImpl) SpringBeanUtils.getBean("xmcDataService");


        Method[] declaredMethods = aClass.getDeclaredMethods();

        Arrays.stream(declaredMethods).forEach(data ->{
            System.out.println(data.getName());
        });

        Object result = null;

        String string = "18797987196";


        Class<? extends XmcDataServiceImpl> aClass1 = xmcDataService.getClass();


        try {
            Method publish = aClass1.getDeclaredMethod("selectList", String.class);

            publish.invoke(xmcDataService,string);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;

    }
}
